<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateDocumentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('qh_documents', function (Blueprint $table) {
            $table->id();
            $table->integer('categoryId', false, true)->nullable()->comment('分类ID');
            $table->string('title')->comment('标题');
            $table->text('thumb')->comment('封面图');
            $table->string('fileFormat')->comment('文件格式');
            $table->decimal('fileSize')->comment('文件大小,单位kb');
            $table->decimal('amount')->default(0)->comment('价格');
            $table->text('file1')->comment('第一个文件');
            $table->text('file2')->nullable()->comment('第二个文件');
            $table->text('previewImages')->comment('预览图数组');
            $table->tinyInteger('previewPage')->default(0)->comment('预览页数');
            $table->integer('totalPage')->default(0)->comment('总页数');
            $table->integer('viewCount')->default(0)->comment('查看/转发数量');
            $table->integer('downloadCount')->default(0)->comment('下载数量');
            $table->integer('sort')->nullable()->comment('排序');
            $table->tinyInteger('disabled')->default(0)->comment('是否禁用, 1 || 0');
            $table->tinyInteger('print')->default(0)->comment('是否打印, 1 || 0');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE qh_documents comment '文档'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('qh_documents');
    }
}
